// https://umijs.org/config/
import { defineConfig } from 'umi';
// import { join } from 'path';
import defaultSettings from './defaultSettings';
import proxy from './proxy';

const { REACT_APP_ENV } = process.env;

export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  layout: {
    // https://umijs.org/zh-CN/plugins/plugin-layout
    locale: true,
    siderWidth: 208,
    ...defaultSettings,
  },
  // https://umijs.org/zh-CN/plugins/plugin-locale
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@ant-design/pro-layout/es/PageLoading',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    // 登录和注册
    {
      path: '/user',
      layout: false,
      routes: [
        {
          path: '/user/login',
          layout: false,
          name: 'login',
          component: './user/Login',
        },
        {
          path: '/user',
          redirect: '/user/login',
        },
        {
          name: 'register-result',
          icon: 'smile',
          path: '/user/register-result',
          component: './user/register-result',
        },
        {
          name: 'register',
          icon: 'smile',
          path: '/user/register',
          component: './user/register',
        },
        {
          component: '404',
        },
      ],
    },
    // 工作台
    {
      name:'work',
      icon:'PieChartOutlined',
      path:'/home',
      component:'./work'
    },
    {
      path:'/userinfo',
      component:'./userinfo'
    },
    //  文章管理
    {
      path: '/form',
      icon: 'form',
      name: 'form',
      routes: [
        {
          path: '/form',
          redirect: '/form/basic-form',
        },
        {
          name: 'basic-form',
          icon: 'form',
          path: '/form/basic-form',
          component: './form/basic-form',
        },
        {
          name: 'step-form',
          icon: 'smile',
          path: '/form/step-form',
          component: './form/step-form',
        },
        {
          name: 'advanced-form',
          icon: 'smile',
          path: '/form/advanced-form',
          component: './form/advanced-form',
        },
           // 新建-编辑
        {
          path:'/form/editor',
          layout: false,
          component:'./detail'
        },
      ],
    },
    {
      name:'page',
      icon:'CopyOutlined',
      path:'/page',
      component:'./page'
    },
    // 知识小册
    {
    name:'knowledge',
    icon:'HighlightOutlined',
    path:'/knowledge',
    component:'./knowledge'
    },
    // 海报管理
    {
    name:'poster',
    icon:'SnippetsOutlined',
    path:'/poster',
    component:'./poster'
    },
    // 评论管理
    {
      name:'comment',
      icon:'CommentOutlined',
      path:'/comment',
      component:'./comment'
    },
    // 邮件管理
    {
      name:'mail',
      icon:'MailOutlined',
      path:'/mail',
      component:'./mail'
    },
     // 文件管理
     {
      name:'file',
      icon:'FolderOpenOutlined',
      path:'/file',
      component:'./file'
    },
      // 搜索记录
    {
        name:'search',
        icon:'SearchOutlined',
        path:'/search',
        component:'./search'
    },
    // 访问统计
    {
        name:'view',
        icon:'SolutionOutlined',
        path:'/view',
        component:'./view'
    },
     // 用户管理
    {
      name:'users',
      icon:'TeamOutlined',
      path:'/users',
      component:'./users'
    },
    // 系统设置
    {
      name:'setting',
      icon:'SettingOutlined',
      path:'/setting',
      component:'./setting'
    },
    // 异常页面
    {
      name: 'exception',
      icon: 'warning',
      path: '/exception',
      routes: [
        {
          path: '/exception',
          redirect: '/exception/403',
        },
        {
          name: '403',
          icon: 'smile',
          path: '/exception/403',
          component: './exception/403',
        },
        {
          name: '404',
          icon: 'smile',
          path: '/exception/404',
          component: './exception/404',
        },
        {
          name: '500',
          icon: 'smile',
          path: '/exception/500',
          component: './exception/500',
        },
      ],
    },
    {
      path: '/',
      redirect: '/user/login',
    },
    {
      component: '404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': defaultSettings.primaryColor,
  },
  // esbuild is father build tools
  // https://umijs.org/plugins/plugin-esbuild
  esbuild: {},
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  // Fast Refresh 热更新
  fastRefresh: {},
  // openAPI: [
  //   {
  //     requestLibPath: "import { request } from 'umi'",
  //     // 或者使用在线的版本
  //     // schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
  //     schemaPath: join(__dirname, 'oneapi.json'),
  //     mock: false,
  //   },
  //   {
  //     requestLibPath: "import { request } from 'umi'",
  //     schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
  //     projectName: 'swagger',
  //   },
  // ],
  nodeModulesTransform: {
    type: 'none',
  },
  mfsu: {},
  webpack5: {},
  exportStatic: {},
});
